< previous page page_634 next page >

Page 634
0634-01.jpg
Figure 17.29
A transparent sphere in front of two other spheres and a polygon.
object's two indexes of refraction N1 and N2 to the same value. Light rays then enter and leave the object, moving in the same direction.
These flat objects ensure that the light travels through them normally by adjusting their surface normals if necessary. In the FindHitColor subroutine, these objects determine whether their normal points toward the center of projection. If it does not, the routine reverses the normal's components so that it does. That gives these objects the same color when they are viewed from either side.
The second way you might use one of these flat objects is as one face of a closed solid like a cube or closed-ended cylinder. In that case you do not want to ignore refraction as light rays pass through the object.
To make flat objects work as the faces of solids, you need to orient them so that the program knows when it is entering and when it is leaving the solid. These objects should not reverse their normals to point toward the center of projection. Then the program can use the normal to tell when it is entering and exiting an object.
The RayFace class implements this feature. It is identical to the RayPolygon class, except it does not change its normal in its FindHitColor subroutine.
Figure 17.30 shows program VBRay displaying a sphere and a transparent prism made up of five RayFace objects.
Assumptions
As is the case with all lighting models, the model used by program VBRay is only an approximation of the true physics of lighting. This model has been adjusted until it produces a fairly interesting and realistic picture under a variety of circumstances, but it is still just an approximation.

 
< previous page page_634 next page >